<include file="public:header" />
<div class="container">
    <h4 style="color: #34789a;" class="text-center">{$info['name']}问卷填写</h4>
    <hr />
    <form id="formBox" role="form" action="__GROUP__?g=api&m=question&a=actAnswer" method="post">
        <input name="questionId" value="{$qid}" type="hidden" />
        <volist name="list['question']" id="v">
            <div class="form-group">
                <label for="v_{$v.id}">{++$key}. {$v.name}</label>
                <!--1为select,2为radio，3为text，4为chackbox-->
                <if condition="$v['type'] eq '3'">
                    <input type="text" name="v[{$v.id}]" class="form-control" value="{$v.value}" id="v_{$v.id}" placeholder="0">
                <elseif condition="$v['type'] eq 2" />
                    <volist name="list['answer'][$v['id']]" id="vv">
                        <div class="radio">
                            <label>
                                <input type="radio" name="v[{$v.id}]" id="optionsRadios{$vv['id']}" value="{$vv['id']}">
                                {$vv['name']}
                            </label>     
                        </div>
                    </volist>     
                <elseif condition="$v['type'] eq 4" />
                    <volist name="list['answer'][$v['id']]" id="vv">
                        <div class="checkbox">
                            <label>
                                <input type="checkbox" name="v[{$v.id}][]" id="optionsRadios{$vv['id']}" value="{$vv['id']}">
                                {$vv['name']}
                            </label>     
                        </div>
                    </volist>                      
                </if>
               
            </div>
        </volist>
        
		<div class="msg alert">
        </div>
        <button type="submit" class="btn btn-primary btn-lg btn-block">提交</button>
    </form>
	<p>&nbsp;</p>
</div>

<script type="text/javascript">
$(document).ready(function(){
    //绑定一个指定的表单
    $('#formBox').ajaxForm({ 
            //设置传输的数据类型
            dataType:  'json', 
            //请求成功后，调用的回调函数
            success:  back
    }); 


	$('.msg').hide();

	$("button").click(function(){
		$('.msg').hide();
		$('.msg').removeClass("alert-success");
		$('.msg').removeClass("alert-danger");
	});
	
    function back(data){
		$('.msg').focus();
        if(data.status === 200){
			$('.msg').addClass("alert-success");
			$('.msg').html(data.msg);
			$('.msg').show();
        }else{
			$('.msg').addClass("alert-danger");
			$('.msg').html(data.msg);
			$('.msg').show();
        }
    }
});

</script>

<include file="public:footer" />